package com.noble.meether.pay.bean;

import android.os.Parcel;
import android.os.Parcelable;

import com.noble.library.base.bean.BaseData;

import org.json.JSONObject;

/**
 * 支付参数
 */
public class Pay extends BaseData implements Parcelable{
    // 支付宝
    private String url;

    // 微信
    private String app_id;
    private String mch_id;
    private String prepay_id;
    private String nonce_str;

    @Override
    public void parseJson(String jsonStr) {
        JSONObject jsonObject = getJsonObject(jsonStr);
        // 支付宝
        this.url = jsonObject.optString("Url");

        // 微信
        this.app_id = jsonObject.optString("AppId");
        this.mch_id = jsonObject.optString("MchId");
        this.prepay_id = jsonObject.optString("PrepayId");
        this.nonce_str = jsonObject.optString("NonceStr");
    }

    public String getUrl() {
        return url;
    }

    public String getApp_id() {
        return app_id;
    }

    public String getMch_id() {
        return mch_id;
    }

    public String getPrepay_id() {
        return prepay_id;
    }

    public String getNonce_str() {
        return nonce_str;
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(this.url);
        dest.writeString(this.app_id);
        dest.writeString(this.mch_id);
        dest.writeString(this.prepay_id);
        dest.writeString(this.nonce_str);
    }

    public Pay() {
    }

    protected Pay(Parcel in) {
        this.url = in.readString();
        this.app_id = in.readString();
        this.mch_id = in.readString();
        this.prepay_id = in.readString();
        this.nonce_str = in.readString();
    }

    public static final Creator<Pay> CREATOR = new Creator<Pay>() {
        @Override
        public Pay createFromParcel(Parcel source) {
            return new Pay(source);
        }

        @Override
        public Pay[] newArray(int size) {
            return new Pay[size];
        }
    };
}
